﻿using Microsoft.AspNetCore.Http;

namespace ApiLib.Models;

/// <summary>
/// 基础认证
/// </summary>
public interface IBaseAuthorization
{
    /// <summary>
    /// 获取token
    /// </summary>
    /// <param name="request"></param>
    /// <returns>返回sid</returns>
    string GetToken(HttpRequest? request = null);

    /// <summary>
    /// 认证方法,根据认证token,从缓存中获取到已登录的用户
    /// </summary>
    /// <param name="request"></param>
    /// <returns>返回sid</returns>
    IBaseUser? Authorization(HttpRequest? request = null);

    /// <summary>
    /// 获取用户,从原始数据(例如数据库)中查询用户
    /// </summary>
    /// <param name="sid"></param>
    /// <returns>返回sid</returns>
    IBaseUser? GetUser(string? sid);
}